<?php
class CrossThemes{
	public function __construct(){
	
	}
	
	public function init(){
		$this->constant();
		
		///// After Setup theme
		add_action( 'after_setup_theme', array($this,'crossthemes_setup'));
		
		add_action('wp_enqueue_scripts',array($this,'addFrontCSS'));
		add_action('wp_enqueue_scripts',array($this,'addFrontJS'));
		
		$this->initFunctions();
		$this->initWidgets();
		
		$this->ImageSizes();
	}
	
	protected function initWidgets(){
		$arrWidgets = array('');
		foreach($arrWidgets as $widget){
			if(file_exists(THEME_WIDGETS."/{$widget}.php"))
			{
				require_once THEME_WIDGETS."/{$widget}.php";
			}	
		}
	}
	
	protected function initFunctions(){
		$arrFunctions = array('megamenu','font-icon','megamenu-front');
		foreach($arrFunctions as $function){
			if(file_exists(THEME_FUNCTIONS."/{$function}.php"))
			{
				require_once THEME_FUNCTIONS."/{$function}.php";
			}	
		}
	}
	
	protected function constant(){
		define('THEME_DIR', get_template_directory());
				
		define('THEME_URI', get_template_directory_uri());
		
		define('THEME_INCLUDES', THEME_DIR . '/includes');
		
		define('THEME_INCLUDES_URI', THEME_URI . '/includes');
		
		define('THEME_FUNCTIONS', THEME_INCLUDES . '/functions');
		
		define('THEME_WIDGETS', THEME_INCLUDES . '/widgets');
		
		define('THEME_HEADERS', THEME_INCLUDES . '/headers');
		
		define('THEME_METABOXS', THEME_INCLUDES . '/metaboxes');
		
		define('THEME_BAKERY', THEME_INCLUDES . '/bakery');
		
		define('THEME_PLUGINS', THEME_INCLUDES . '/plugins');
		
		define('THEME_IMAGES', THEME_URI . '/images');
		
		define('THEME_CSS', THEME_URI . '/css');
		
		define('THEME_JS', THEME_URI . '/js');
	}
	
	public function crossthemes_setup(){
		load_theme_textdomain( 'crossthemes', get_template_directory() . '/languages' );
		
		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );
		
		add_theme_support( 'post-thumbnails' );
		
		add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'));
		
		if ( ! isset( $content_width ) ) $content_width = 1200;
		
		// This theme uses wp_nav_menu() in one location.
		register_nav_menus( array(
			'primary' => __( 'Primary Navigation', 'crossthemes' )
		) );
	}
	
	public function addFrontCSS(){

		wp_register_style( 'colorpicker', THEME_CSS.'/colorpicker.css');
		wp_enqueue_style('colorpicker');
		
		wp_register_style( 'bootstrap', THEME_CSS.'/bootstrap.css');
		wp_enqueue_style('bootstrap');
		
		wp_register_style( 'bootstrap-theme', THEME_CSS.'/bootstrap-theme.css');
		wp_enqueue_style('bootstrap-theme');
		
		wp_register_style( 'font-awesome', THEME_CSS.'/font-awesome.css');
		wp_enqueue_style('font-awesome');
		
		wp_register_style( 'css_wd_menu_frontend', THEME_CSS.'/megamenu.css');
		wp_enqueue_style('css_wd_menu_frontend');
	
		wp_register_style( 'select2', THEME_CSS.'/select2.css');
		wp_enqueue_style('select2');
		
		wp_register_style( 'css.prettyPhoto', THEME_CSS.'/prettyPhoto.css');
		wp_enqueue_style('css.prettyPhoto');
	}
	
	public function addFrontJS(){
		wp_enqueue_script('jquery');	
		
		wp_register_script( 'bootstrap', THEME_JS.'/bootstrap.js',false,false,true);
		wp_enqueue_script('bootstrap');	

		wp_register_script( 'TweenMax', THEME_JS.'/TweenMax.min.js',false,false,true);
		wp_enqueue_script('TweenMax');

		wp_register_script( 'bootstrap-colorpicker', THEME_JS.'/bootstrap-colorpicker.js',false,false,true);
		wp_enqueue_script('bootstrap-colorpicker');

		wp_register_script( 'jquery.select2', THEME_JS.'/select2.js',false,false,true);
		wp_enqueue_script('jquery.select2');

		wp_register_script( 'jquery.prettyPhoto', THEME_JS.'/jquery.prettyPhoto.min.js',false,false,true);
		wp_enqueue_script('jquery.prettyPhoto');
		
		wp_register_script( 'jquery.prettyPhoto.init', THEME_JS.'/jquery.prettyPhoto.init.min.js',false,false,true);
		wp_enqueue_script('jquery.prettyPhoto.init');	

		wp_enqueue_style( 'wp_base', get_stylesheet_uri() ); 	
			
	}
	
	public function ImageSizes(){
		if ( function_exists( 'add_image_size' ) ) {
			add_image_size('blog_thumb',880,565,true); /* image for blog thumbnail */
		}
	}
}